/*
 * @lc app=leetcode.cn id=283 lang=swift
 *
 * [283] 移动零
 */

// @lc code=start
class Solution {
    func moveZeroes(_ nums: inout [Int]) {
        var left = 0, right = 0
        while right < nums.count {
            if nums[right] == 0 {
                right += 1
                continue
            }
            if left != right {
                nums[left] = nums[right]
            }
            left += 1
            right += 1
        }
        for i in left..<nums.count {
            nums[i] = 0
        }
    }
}
// @lc code=end

